package cc3002;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;


/**
 * JUnit Test class : Food
 * -----------------------
 * I will test every method on this class, they're very important for the extended classes to work.
 * @author Anibal Llanos Prado
 *
 */
public class FoodTest {
	
	/**
	 * Fixtures. We will use the deprecated constructor only for testing that it still works.
	 */
	protected Food food1, food2;
	protected int bites;
	protected String name1="food", name2="Food";
	
	/**
	 * Setup method.
	 */
	@SuppressWarnings("deprecation")
	@Before
	public void setUp() throws Exception {
		food1=new Food(name1,100);
		food2=new Food();
		bites=1;
	}

	/**
	 * Test method for {@link cc3002.Food#bite(cc3002.HealthState)}.
	 */
	@SuppressWarnings("deprecation")
	@Test
	public void testBite() {
		assertEquals(food1.bite(new HealthState()), 100);
		assertEquals(food2.bite(new HealthState()), 300);
		food1 = new Food(name1, 200);
		food2 = new Food();
		food2.setCalories(500);
		assertEquals(food1.bite(new HealthState()), 200);
		assertEquals(food1.bite(new HealthState()), 0);
		assertEquals(food2.bite(new HealthState()), 500);
		
	}

	/**
	 * Test method for {@link cc3002.Food#setName(java.lang.String)}.
	 */
	@Test
	public void testSetName() {
		food1.setName("meat");
		food2.setName("Carrot");
		assertEquals(food1.getName(),"meat");
		assertEquals(food2.getName(),"Carrot");

		
	}

	/**
	 * Test method for {@link cc3002.Food#getFullName()}.
	 */
	@Test
	public void testGetFullName() {
		food1.setName(name1); food2.setName(name2);
		assertEquals(food1.getFullName(),name1+"("+food1.getRemainingBites()+" bites remaining)");
		assertEquals(food2.getFullName(),name2+"("+food1.getRemainingBites()+" bites remaining)");
	}

	/**
	 * Test method for {@link cc3002.Food#getName()}.
	 */
	@Test
	public void testGetName() {
		food1.setName(name1); food2.setName(name2);
		assertFalse(food1.getName().equals(food2.getName()));
		assertEquals(food1.getName(),name1);
		assertEquals(food2.getName(),name2);
	}

	/**
	 * Test method for {@link cc3002.Food#setCalories(int)}.
	 */
	@Test
	public void testSetCalories() {
		food1.setCalories(5);
		food2.setCalories(10);
		assertEquals(food1.bite(new HealthState()), 5);
		assertEquals(food2.bite(new HealthState()), 10);
	}
	
	/**
	 * Test method for {@link cc3002.Food#getRemainingBites()}.
	 */
	@Test
	public void testGetRemainingBites() {
		assertEquals(food1.getRemainingBites(),bites);
	}

}
